<?php
/**
 * Created by HTD
 * QQ:387938921
 * TEL:18868809048
 * on 2017/5/5 13:51.
 */


namespace common\libs;



use common\helpers\ArrayHelpers;

class Constants
{
    const TabSize = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

    CONST ONLINE_TIME = 1469030400;//2016年7月21号
    //获取上线天数
    public static function getOnlineDaysCount()
    {
        return (strtotime(date('Y-m-d')) - self::ONLINE_TIME) / 86400;
    }

    //最大登录错误次数
    CONST MAX_LOGIN_ERROR_TIMES = 3;

    public static function getSortNum()
    {
        return time();
    }

    const YesNo_Yes = 1;
    const YesNo_No = 0;
    public static function getYesNoItems($key = null)
    {
        $items = [
            self::YesNo_Yes => '是',
            self::YesNo_No => '否'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    const Status_Enable = 1;
    const Status_Disable = 0;
    public static function getStatusItems($key = null)
    {
        $items = [
            self::Status_Enable => '可用',
            self::Status_Disable => '禁用'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    CONST BACK_TYPE_ADMIN = 'admin';
    CONST BACK_TYPE_GUILD = 'guild';
    public static function getBackType($key = null){
        $items = [
            self::BACK_TYPE_ADMIN => '优趣后台',
            self::BACK_TYPE_GUILD => '公会后台'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    /**
     * 订单状态目前只有Pay表在使用
     */
    const Status_Success = 1;
    const Status_Untreated = 0;
    const Status_Faild = 2;
    public static function getOrderStatusItems($key = null)
    {
        $items = [
            self::Status_Success => '成功',
            self::Status_Untreated => '未处理',
            self::Status_Faild => '失败'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    /**
     * 订单状态目前只有Pay表在使用
     */
    const Server_Open = 1;
    const Server_Close = 0;
    const Server_Soon = 2;
    public static function getServerStatusItems($key = null)
    {
        $items = [
            self::Server_Open => '开启',
            self::Server_Close => '关闭',
            self::Server_Soon => '即将开服'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    const Target_Self = '_self';
    const Target_blank = '_blank';
    public static function getTargetItems($key = null)
    {
        $items = [
            self::Target_Self => '当前窗口',
            self::Target_blank => '新窗口'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    const Visibility_Public = '1';
    const Visibility_Hidden = '2';
    const Visibility_Password = '3';
    const Visibility_Private = '4';
    public static function getVisibilityItems($key = null)
    {
        $items = [
            self::Visibility_Public => '公开',
            self::Visibility_Hidden => '回复可见',
            self::Visibility_Password => '密码保护',
            self::Visibility_Private => '私有'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    const Status_Publish = '1';
    const Status_Draft = '2';
    const Status_Pending = '3';
    public static function getStatusItemsForContent($key = null)
    {
        $items = [
            self::Status_Publish => '发布',
            self::Status_Draft => '草稿',
            self::Status_Pending => '等待审核'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    /* game API type*/
    const Api_Login = 'login';
    const Api_Recharge = 'recharge';
    const Api_Role = 'role';
    const Api_Tryplay = 'tryplay';
    public static function getApiTypeItems($key = null)
    {
        $items = [
            self::Api_Login => '游戏登录接口',
            self::Api_Recharge => '游戏充值接口',
            self::Api_Tryplay => '试玩角色查询接口',
            self::Api_Role => '游戏角色接口'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    /* stitching parameter */
    const Montage_True = 1;
    const Montage_False = 0;


    /* 时间单位转换为秒 */
    CONST ONE_MINUTE = 60;//1分钟
    CONST FIVE_MINUTES = 300;//5分钟
    CONST TEN_MINUTES = 600;//10分钟
    CONST ONE_HOUR = 3600;//1小时
    CONST ONE_DAY = 86400;//1天
    CONST ONE_WEEK = 604800;//1周

    /* Cache Keys */
    CONST KEY_BANNAR = 'bannar';
    CONST KEY_REGISTER_TODAY = 'register_today';
    CONST KEY_REGISTER = 'register';
    CONST KEY_REGISTER_LAST_TEN_DAY = 'register_last_ten_day';
    CONST KEY_REGISTER_HOURLY = 'register_hourly';
    CONST KEY_GAME = 'game';
    CONST KEY_HOT_GAME = 'hot_game';
    CONST KEY_BEST_GAME = 'best_game';
    CONST KEY_BOUTIQUE_GAME = 'boutique_game';
    CONST KEY_LATEST_SERVER = 'latest_server';
    CONST KEY_PAY_TODAY = 'pay_today';
    CONST KEY_PAY = 'pay';
    CONST KEY_PAY_MONTHLY = 'pay_monthly';
    CONST KEY_PAY_CHANNEL = 'pay_channel';
    CONST KEY_PAY_CHANNEL_DAILY = 'pay_channel_daily';
    CONST KEY_PAY_CHANNEL_PIE = 'pay_channel_pie';
    CONST KEY_PAY_GAME = 'pay_game';

    /* pay mode no */
    CONST PAY_SNDA = 'YRSHENGPAY';
    CONST PAY_CARD = 'CARDPAY';
    CONST PAY_UQ = 'UQPAY';
    CONST PAY_WX = 'WXPAY';
    CONST PAY_WX_ZX = 'WXPAYZX';
    CONST PAY_ALI_ZX = 'ALIPAYZX';
    CONST PAY_ALI_ZR = 'ALIPAYZR';
    CONST PAY_WX_ZR = 'WXPAYZR';
    CONST PAY_ALI = 'ZHIFUBAO';
    CONST PAY_ALI_WEB = 'ZHIFUBAOWAP';
    public static function getPayTypeItems($key = null)
    {
        $items = [
            self::PAY_SNDA => '盛付通',
            self::PAY_CARD => '充值卡',
            self::PAY_UQ => '优趣币',
            self::PAY_WX => '微信支付',
            self::PAY_WX_ZX => '中信微信支付',
            self::PAY_ALI_ZX => '支付宝中信',
            self::PAY_ALI_ZR => '支付宝中润',
            self::PAY_WX_ZR => '微信支付中润',
            self::PAY_ALI=>'支付宝',
            self::PAY_ALI_WEB=>'支付宝网页'

        ];
        return ArrayHelpers::getItems($items, $key);
    }

    CONST PAY_TO_GAME = 'game';
    CONST PAY_TO_UQB = 'uqb';
    CONST PAY_TO_IN = 'in';
    CONST PAY_TO_BACK_GAME = 'back_game';
    CONST PAY_TO_FIRST_BACK_GAME = 'first_back_game';
    CONST COOPRATE_PAY_TO_GAME = 'cooprate_to_game';

    public static function getPayToItems($key = null)
    {
        $items = [
            self::PAY_TO_GAME => '渠道-游戏',
            self::PAY_TO_UQB => '渠道-优趣币',
            self::PAY_TO_IN => '后台-内充',
            self::PAY_TO_BACK_GAME => '后台-返利',
            self::PAY_TO_FIRST_BACK_GAME => '后台-首充',
            self::COOPRATE_PAY_TO_GAME=>'合作-游戏'
        ];
        return ArrayHelpers::getItems($items, $key);
    }


    /*transaction types for bill table*/
    CONST PAY_EARN = 1;
    CONST PAY_OUT = 2;

    /* game type */

    CONST GAME_TYPE_MIX = 1;
    CONST GAME_TYPE_UQUQ = 0;
    CONST GAME_TYPE_3D = 2;
    public static function getGameTypeItems($key = null)
    {
        $items = [
            self::GAME_TYPE_MIX => '混服游戏',
            self::GAME_TYPE_UQUQ => '微端网页游戏',
            self::GAME_TYPE_3D => '微端游戏',

        ];
        return ArrayHelpers::getItems($items, $key);
    }

    /*mode type*/
    CONST MODE_TYPE_BOTH = 1;
    CONST MODE_TYPE_NOTIFY = 2;
    public static function getModeTypeItems($key = null)
    {
        $items = [
            self::MODE_TYPE_BOTH => '同异步共同返回订单状态',
            self::MODE_TYPE_NOTIFY => '异步返回订单状态',

        ];
        return ArrayHelpers::getItems($items, $key);
    }

    /*game pay type */
    CONST PAY_TYPE_GAME_MIX = 1;
    CONST PAY_TYPE_GAME_UQUQ = 0;

    /*game login type*/
    CONST LOGIN_TYPE_PC = 1;
    CONST LOGIN_TYPE_WEB = 0;

    /* 推广渠道类型 */
    CONST HANNELS_SERVER = 1;
    CONST HANNELS_DEMO = 2;
    CONST HANNELS_AD = 3;
    CONST HANNELS_PRIVATE = 4;
    CONST HANNELS_OTHER = 5;
    public static function getHannelsItems($key = null)
    {
        $items = [
            self::HANNELS_SERVER => '开服表',
            self::HANNELS_DEMO => '试玩',
            self::HANNELS_AD => '广告',
            self::HANNELS_PRIVATE => '私服',
            self::HANNELS_OTHER => '其他',
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    public static function getRecommendItems($key = null)
    {
        $items = [
            // 0 => '无',
            1 => '一级推荐',
            2 => '二级推荐',
            3 => '三级推荐',
            4 => '四级推荐',
            5 => '五级推荐',
            6 => '六级推荐',
            7 => '七级推荐',
            8 => '八级推荐',
            9 => '九级推荐'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    public static function getHeadlineItems($key = null)
    {
        $items = [
            // 0 => '无',
            1 => '一级头条',
            2 => '二级头条',
            3 => '三级头条',
            4 => '四级头条',
            5 => '五级头条',
            6 => '六级头条',
            7 => '七级头条',
            8 => '八级头条',
            9 => '九级头条'
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    public static function getStickyItems($key = null)
    {
        $items = [
            // 0 => '无',
            1 => '一级置顶',
            2 => '二级置顶',
            3 => '三级置顶',
            4 => '四级置顶',
            5 => '五级置顶',
            6 => '六级置顶',
            7 => '七级置顶',
            8 => '八级置顶',
            9 => '九级置顶'
        ];

        return ArrayHelpers::getItems($items, $key);
    }

    CONST GAME_OPEN_API_ERROR = -1;
    CONST SUCCESS = 1;
    CONST NO_GAME = 2;
    CONST NO_SERVER = 3;
    CONST NO_PID = 4;
    CONST SIGN_ERROR = 5;
    CONST ORDER_EXIST = 6;
    CONST SERVER_NOT_START = 7;
    CONST TIME_ERROR = 8;
    CONST COIN_ERROR = 9;
    CONST ROLE_ERROR = 10;
    public static function getGameOpenApiStatusItem($key = null)
    {
        $items = [
            self::GAME_OPEN_API_ERROR => 'unknown error',
            self::SUCCESS => 'success',
            self::NO_GAME => 'no game',
            self::NO_SERVER => 'no server',
            self::NO_PID => 'no pid',
            self::SIGN_ERROR => 'sign error',
            self::ORDER_EXIST => 'order exist',
            self::SERVER_NOT_START => 'server not start',
            self::TIME_ERROR => 'time error',
            self::COIN_ERROR => 'coin error',
            self::ROLE_ERROR => 'role not exist',
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    CONST COOPERATE = "cooperate";
    CONST ANCHOR = "anchor";

    CONST IS_DEDUCTED = 1;
    CONST NOT_DEDUCTED = 0;
    public static function getDeductedStatus($key = null)
    {
        $items = [
            self::IS_DEDUCTED => '扣量',
            self::NOT_DEDUCTED => '不扣量',
        ];
        return ArrayHelpers::getItems($items, $key);
    }

    CONST Article_strategy = 22;


    //连接所有参数后直接md5加密（例：md5(a+b+c+d)）
    CONST SIGN_TYPE_MD5 = "md5";
    //连接时需要参数名并且md5加密（例：md5(a=a&b=b&c=c{$key})）
    CONST SIGN_TYPE_QUERY_MD5 = "md5_";
    CONST SIGN_TYPE_BASE64 = "base64";
    //连接时需要参数名并且md5加密（例：md5(a=a&b=b&c=c&{$key})）
    CONST SIGN_TYPE_NAME_VALUE_MD5 = "md5nv";
    //连接时需要参数名并且md5加密（例：md5(a=a&b=b&c=c&key=key)）
    CONST SIGN_TYPE_HTTP_QUERY_MD5 = "md5hq";
    //先进行auth参数的base64加密，再进行md5签名
    CONST SIGN_TYPE_AUTH_MD5 = "md5auth";

    CONST STATUS_RESET_PWD_NOT_CONFIRM = 4;
    CONST STATUS_RESET_PWD_NOT_LOGIN = 3;
    CONST STATUS_RESET_PWD_ERROR_PWD = 2;
    CONST STATUS_RESET_PWD_SUCCESS = 1;


    /* Role Names */
    const ROLE_GUILD_CHANNEL = '公会推广员';
    const ROLE_GUILD_MANAGER = '公会管理员';






}